Your Mission 🎯
Reconnect $N$ planets, given as 2D coordinates, with a minimum-cost "Hyper-lane" network.
- 目标: Connect all $N$ planets (vertices) so they are all reachable (directly or indirectly).
- 目标: Find the network design that minimizes the **total cost**.
Analysis 🛰️
The cost of a lane (edge) is the Euclidean distance:
$d = \sqrt{(x_1 - x_2)^2 + (y_1 - y_2)^2}$
- 任意两个行星之间都可以建造一条航道。任意 two planets.
- 这意味着我们拥有一个完全(稠密)图。
The Solution ⚙️
This is a classic 最小生成树(MST) problem.
- 算法: The hint recommends 普里姆算法(Prim's Algorithm) (the $O(V^2)$ version), which is perfect for dense graphs.
- 起始点: We will start our algorithm from 行星 0 for a consistent result.
一个完全图(左侧)包含所有可能的边;最小生成树(右侧)是连接所有顶点的最廉价边的子集。